<%--
  Created by IntelliJ IDEA.
  User: 13935999517
  Date: 2023/12/25
  Time: 11:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <style>
        .footer {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        input {
            width: 50%;
        }

    </style>
</head>
<body>
<div class="skin-default" id="wrapper">
    <%@include file="/static/pages/head/header.jsp" %>
    <div class="page-wrapper">
        <div class="page-header">
            <h1 class="title">
                出库操作
            </h1>
        </div>
        <section class="page-body">
            <div class="row widget">
                <section class="col-md-12">
                    <div class="box table">
                        <div class="box-body">
                            <p></p>
                            <form class="form-horizontal" action="${pageContext.request.contextPath}/out/add"
                                  method="post">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">选择入库编码:</label>
                                    <div class="col-sm-10">
                                        <select class="form-control" style="width: 600px" name="mysel">
                                            <option value="-1">请选择</option>
                                            <c:forEach items="${instores}" var="instore">
                                                <option value="${instore.inId}" name="option">${instore.inCode}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </div>

                                <input type="hidden" name="inId">
                                <input type="hidden" name="productId">
                                <input type="hidden" name="wasteId">
                                <input type="hidden" name="containerId">
                                <input type="hidden" name="userId">
                                <input type="hidden" name="companyId">
                                <input type="hidden" name="productCode">
                                <input type="hidden" name="wasteCode">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">入库单位:</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="inUnit" readonly>
                                    </div>
                                </div>
                                <%--<div class="form-group">
                                    <label class="col-sm-2 control-label">入库时间:</label>
                                    <div class="col-sm-10">
                                        <input type="date" class="form-control" name="inTime" readonly>
                                    </div>
                                </div>--%>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">行业来源:</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="wasteSource" readonly>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">危险废物:</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="wasteHazardous" readonly>
                                    </div>
                                </div>
                                <%--<div class="form-group">
                                    <label class="col-sm-2 control-label">行业俗称:</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="wasteCommonname" readonly>
                                    </div>
                                </div>--%>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">废物类别名称:</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="typeName" readonly>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">容器编码:</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="containerCode" readonly>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">出库量:</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="inNum">
                                        <input type="hidden" title="num">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">选择出库方式:</label>
                                    <select class="form-control" style="width: 600px" name="outStatus" id="mysele2">
                                        <option value="-1">请选择</option>
                                        <option value="0">自行利用</option>
                                        <option value="1">委外处理</option>
                                    </select>
                                </div>
                                <%--两种方式都用的处理方式--%>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">处理方式:</label>
                                    <select class="form-control" style="width: 600px" name="outType">
                                        <option value="-1">请选择</option>
                                        <option value="1">焚烧</option>
                                        <option value="2">水载</option>
                                        <option value="3">填埋</option>
                                    </select>
                                </div>
                                <%--委外处理的司机--%>
                                <div class="form-group" style="display: none" id="mysele3">
                                    <label class="col-sm-2 control-label">选择司机:</label>
                                    <select class="form-control" style="width: 600px" >
                                        <option value="-1">请选择</option>
                                        <c:forEach items="${driverList}" var="driver">
                                            <option value="${driver.driverId}">${driver.driverName}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" class="btn btn-primary">提交</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </section>
            </div>
        </section>
    </div>
</div>
</body>
<script>
    $(function () {

    })


    $("#mysele2").change(function () {
        var val = $(this).find('option:selected').val();//获取的选中的option值
        if(val==1){
            $("#mysele3").css("display","block")
        }else{
            $("#mysele3").css("display","none")
        }
    })

    $("[name='inNum']").blur(function () {
        var a = $(this).val();
        var b = $("[title='num']").val();
        if (parseInt(a) > parseInt(b)) {
            alert("库存不足")
        }
    })

    $("[name='mysel']").change(function () {
        var val = $(this).find('option:selected').val();//获取的选中的option值
        $.ajax({
            type: "GET",
            url: "${pageContext.request.contextPath}/out/list/" + val,
            dataType: "json",
            success: function (res) {
                console.log(res)
                $("[name='inId']").val(res.inId);
                $("[name='inUnit']").val(res.inUnit);
                // $("[name='inTime']").val(new Date(res.inTime));
                $("[name='wasteSource']").val(res.wasteSource);
                $("[name='wasteHazardous']").val(res.wasteHazardous);
                $("[name='typeName']").val(res.typeName);
                $("[name='containerCode']").val(res.containerCode);
                $("[name='wasteCommonname']").val(res.wasteCommonname);
                $("[name='productId']").val(res.productId);
                $("[name='productCode']").val(res.productCode);
                $("[name='wasteId']").val(res.wasteId);
                $("[name='wasteCode']").val(res.wasteCode);
                $("[name='containerId']").val(res.containerId);
                $("[name='companyId']").val(res.companyId);

                $("[title='num']").val(res.inNum);
            }
        })

    })

    /* $("[type='button']").click(function () {
         var inUnit = $("[name='inUnit']").val();
         var inTime = $("[name='inTime']").val();
         var wasteSource = $("[name='wasteSource']").val()
         var wasteHazardous = $("[name='wasteHazardous']").val()
         var wasteCommonname = $("[name='wasteCommonname']").val()
         var typeName = $("[name='typeName']").val()
         var containerCode = $("[name='containerCode']").val();

         var productId = $("[name='productId']").val()
         var wasteId = $("[name='wasteId']").val()
         var containerId =  $("[name='containerId']").val()
         var userId =  $("[name='userId']").val()
         var companyId = $("[name='companyId']").val()

        $.ajax({
             type: "get",
             url: "${pageContext.request.contextPath}/out/add",
            data:{
                inUnit:inUnit,
                inTime:inTime,
                wasteSource:wasteSource,
                wasteHazardous:wasteHazardous,
                wasteCommonname:wasteCommonname,
                typeName:typeName,
                containerCode:containerCode,
                productId:productId,
                wasteId:wasteId,
                containerId:containerId,
                userId:userId,
                companyId:companyId
            },
            success: function (res) {

            }
        })

    })*/


</script>
</html>
